package com.test.demo.controller;

import com.test.demo.model.Loan;
import com.test.demo.service.LoanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * 作者：孙志颖
 */
@RestController(value = "/Loan")
public class LoanController {
    @Autowired
    private LoanService loanService;

    @CrossOrigin
    @RequestMapping(value = "/getOnez")
    public Loan getOnez(Integer lid) {
        return loanService.selectByPrimaryKey(lid);
    }
    @CrossOrigin
    @RequestMapping(value = "getLId")
    public List<Loan> getLId(){
        System.out.println("调用角色全部类型的接口");
        List<Loan> listLoan =loanService.getLId();
        return listLoan;
    }
    @CrossOrigin
    @RequestMapping(value="/getAllz")
    public List<Loan> getAllz(){
        System.out.println("调用角色全部信息的方法");
        return loanService.getAllz();
    }
    @CrossOrigin
    @RequestMapping(value = "/delLoan",method = RequestMethod.GET)
    public int delLoan(Integer lid){
        return loanService.delLoan(lid);
    }
    @CrossOrigin
    @RequestMapping(value = "/addLoan",method = RequestMethod.PUT)
    public int addRole(@RequestBody Loan loanmodel){
        //判断传入参数是否为空
        if (loanmodel!=null){

        }else {

        }
        return loanService.insertLoan(loanmodel);
    }
    @CrossOrigin
    @RequestMapping(value = "/updateLoan",method = RequestMethod.PUT)
    public int updateLoan(@RequestBody Loan loanmodel){
        return loanService.updateLoan(loanmodel);
    }
}
